home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / pcomm2 / part06 < prev    next >
Encoding:
Internet Message Format  |  1988-09-14  |  49.2 KB

  1. Path: bbn.com!rsalz
  2. From: rsalz@uunet.uu.net (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v16i011:  Modem communications package, Part06/08
  5. Message-ID: <1063@fig.bbn.com>
  6. Date: 13 Sep 88 16:44:47 GMT
  7. Lines: 2004
  8. Approved: rsalz@uunet.UU.NET
  9.  
  10. Submitted-by: Emmet P Gray <fthood!egray>
  11. Posting-number: Volume 16, Issue 11
  12. Archive-name: pcomm2/part06
  13.  
  14. #! /bin/sh
  15. # This is a shell archive, meaning:
  16. # 1. Remove everything above the #! /bin/sh line.
  17. # 2. Save the resulting text in a file.
  18. # 3. Execute the file with /bin/sh (not csh) to create:
  19. #    s_axfer.c
  20. #    s_gen.c
  21. #    s_menu.c
  22. #    s_modem.c
  23. #    s_prompt.c
  24. #    s_term.c
  25. #    s_tty.c
  26. #    screen.c
  27. #    st_line.c
  28. #    strings.c
  29. #    terminal.c
  30. export PATH; PATH=/bin:/usr/bin:$PATH
  31. echo shar: "extracting 's_axfer.c'" '(3938 characters)'
  32. if test -f 's_axfer.c'
  33. then
  34.     echo shar: "will not over-write existing file 's_axfer.c'"
  35. else
  36. sed 's/^X//' << \SHAR_EOF > 's_axfer.c'
  37. X/*
  38. X * Display the ASCII transfer setup, query for changes.  A return code
  39. X * of 1 means something was changed.
  40. X */
  41. X
  42. X#include <stdio.h>
  43. X#include <curses.h>
  44. X#include "config.h"
  45. X#include "misc.h"
  46. X#include "param.h"
  47. X
  48. Xint
  49. Xaxfer_setup()
  50. X{
  51. X    extern char *v_yes[];
  52. X    WINDOW *x_win, *newwin();
  53. X    int i, ret_code, num;
  54. X    char *ans, *menu_prompt(), *strdup();
  55. X    void free_ptr();
  56. X    static char *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  57. X    static char *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  58. X    static char *v_delay[4] = {"0", "100", "150", NULL};
  59. X
  60. X    x_win = newwin(23, 80, 0, 0);
  61. X
  62. X    horizontal(x_win, 0, 0, 28);
  63. X    mvwattrstr(x_win, 0, 29, A_BOLD, "ASCII Transfer Setup");
  64. X    horizontal(x_win, 0, 50, 29);
  65. X    mvwaddstr(x_win, 3, 34, "ASCII UPLOAD");
  66. X    mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  67. X    mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  68. X    mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  69. X    mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  70. X    mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  71. X    mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  72. X    mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  73. X    mvwprintw(x_win, 14, 22, "7) Transfer timeout (sec) . %d", param->timer);
  74. X    mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  75. X    mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  76. X    horizontal(x_win, 19, 0, 80);
  77. X    mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  78. X    mvwaddstr(x_win, 20, 58, "Press <ESC> to return");
  79. X    wmove(x_win, 20, 12);
  80. X    touchwin(x_win);
  81. X    wrefresh(x_win);
  82. X                    /* get the option number */
  83. X    ret_code = 0;
  84. X    while ((i = get_num(x_win, 1)) != -1) {
  85. X        switch (i) {
  86. X            case 1:
  87. X                if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  88. X                    free_ptr(param->lecho);
  89. X                    param->lecho = strdup(ans);
  90. X                    ret_code++;
  91. X                }
  92. X                break;
  93. X            case 2:
  94. X                if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  95. X                    free_ptr(param->expand);
  96. X                    param->expand = strdup(ans);
  97. X                    ret_code++;
  98. X                }
  99. X                break;
  100. X            case 3:
  101. X                if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  102. X                    param->cr_delay = atoi(ans);
  103. X                    ret_code++;
  104. X                }
  105. X                break;
  106. X            case 4:
  107. X                if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  108. X                    free_ptr(param->pace);
  109. X                    param->pace = strdup(ans);
  110. X                    ret_code++;
  111. X                }
  112. X                break;
  113. X            case 5:
  114. X                if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  115. X                    free_ptr(param->cr_up);
  116. X                    param->cr_up = strdup(ans);
  117. X                    ret_code++;
  118. X                }
  119. X                break;
  120. X            case 6:
  121. X                if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  122. X                    free_ptr(param->lf_up);
  123. X                    param->lf_up = strdup(ans);
  124. X                    ret_code++;
  125. X                }
  126. X                break;
  127. X            case 7:
  128. X                if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", "(in seconds)")) != -1) {
  129. X                    if (num > MAX_TIMER || num < MIN_TIMER) {
  130. X                        beep();
  131. X                    /* some reasonable range of values */
  132. X                        if (num < MIN_TIMER)
  133. X                            num = MIN_TIMER;
  134. X                        else
  135. X                            num = MAX_TIMER;
  136. X                        mvwaddstr(x_win, 14, 50, "   ");
  137. X                        wrefresh(x_win);
  138. X                        mvwattrnum(x_win, 14, 50, A_BOLD, num);
  139. X                        wrefresh(x_win);
  140. X                    }
  141. X                    param->timer = num;
  142. X                    ret_code++;
  143. X                }
  144. X                break;
  145. X            case 8:
  146. X                if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  147. X                    free_ptr(param->cr_dn);
  148. X                    param->cr_dn = strdup(ans);
  149. X                    ret_code++;
  150. X                }
  151. X                break;
  152. X            case 9:
  153. X                if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  154. X                    free_ptr(param->lf_dn);
  155. X                    param->lf_dn = strdup(ans);
  156. X                    ret_code++;
  157. X                }
  158. X                break;
  159. X            default:
  160. X                beep();
  161. X        }
  162. X        mvwaddch(x_win, 20, 12, (chtype) ' ');
  163. X        clear_line(x_win, 21, 0, 0);
  164. X        clear_line(x_win, 22, 0, 0);
  165. X        wmove(x_win, 20, 12);
  166. X        wrefresh(x_win);
  167. X    }
  168. X    delwin(x_win);
  169. X    return(ret_code);
  170. X}
  171. SHAR_EOF
  172. if test 3938 -ne "`wc -c < 's_axfer.c'`"
  173. then
  174.     echo shar: "error transmitting 's_axfer.c'" '(should have been 3938 characters)'
  175. fi
  176. fi
  177. echo shar: "extracting 's_gen.c'" '(4457 characters)'
  178. if test -f 's_gen.c'
  179. then
  180.     echo shar: "will not over-write existing file 's_gen.c'"
  181. else
  182. sed 's/^X//' << \SHAR_EOF > 's_gen.c'
  183. X/*
  184. X * Display the general setup, query for changes.  A return code of 1
  185. X * means something was changed.
  186. X */
  187. X
  188. X#include <stdio.h>
  189. X#include <curses.h>
  190. X#include "config.h"
  191. X#include "misc.h"
  192. X#include "param.h"
  193. X
  194. Xint
  195. Xgen_setup()
  196. X{
  197. X    extern char *v_yes[];
  198. X    WINDOW *g_win, *newwin();
  199. X    int i, num, ret_code;
  200. X    char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  201. X    char *strdup();
  202. X    void free_ptr(), line_set();
  203. X    static char *v_abort[3] = {"KEEP", "DELETE", NULL};
  204. X
  205. X    g_win = newwin(23, 80, 0, 0);
  206. X
  207. X    horizontal(g_win, 0, 0, 32);
  208. X    mvwattrstr(g_win, 0, 33, A_BOLD, "General Setup");
  209. X    horizontal(g_win, 0, 47, 32);
  210. X    mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  211. X    mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  212. X    mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  213. X    mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  214. X    mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  215. X    mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  216. X    mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  217. X    mvwprintw(g_win, 12, 22, "8) Break character ........ %c", param->brk_char);
  218. X    mvwprintw(g_win, 14, 22, "9) Aborted downloads ...... %s", param->abort);
  219. X    mvwprintw(g_win, 16, 21, "10) Connect delay (sec) .... %d", param->c_delay);
  220. X    mvwprintw(g_win, 17, 21, "11) Redial delay (sec) ..... %d", param->r_delay);
  221. X    horizontal(g_win, 19, 0, 80);
  222. X    mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  223. X    mvwaddstr(g_win, 20, 58, "Press <ESC> to return");
  224. X    wmove(g_win, 20, 12);
  225. X    touchwin(g_win);
  226. X    wrefresh(g_win);
  227. X                    /* get the option number */
  228. X    ret_code = 0;
  229. X    while ((i = get_num(g_win, 2)) != -1) {
  230. X        switch (i) {
  231. X            case 1:
  232. X                if ((ans = str_prompt(g_win, 3, 50, "Default log file", "")) != NULL) {
  233. X                    free_ptr(param->logfile);
  234. X                    param->logfile = strdup(ans);
  235. X                    ret_code++;
  236. X                }
  237. X                break;
  238. X            case 2:
  239. X                if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", "")) != NULL) {
  240. X                    free_ptr(param->dumpfile);
  241. X                    param->dumpfile = strdup(ans);
  242. X                    ret_code++;
  243. X                }
  244. X                break;
  245. X            case 3:
  246. X                if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit?", v_yes)) != NULL) {
  247. X                    free_ptr(param->strip);
  248. X                    param->strip = strdup(ans);
  249. X                    line_set();
  250. X                    ret_code++;
  251. X                }
  252. X                break;
  253. X            case 4:
  254. X                if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != NULL) {
  255. X                    param->pause_char = c;
  256. X                    ret_code++;
  257. X                }
  258. X                break;
  259. X            case 5:
  260. X                if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != NULL) {
  261. X                    param->cr_char = c;
  262. X                    ret_code++;
  263. X                }
  264. X                break;
  265. X            case 6:
  266. X                if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != NULL) {
  267. X                    param->ctrl_char = c;
  268. X                    ret_code++;
  269. X                }
  270. X                break;
  271. X            case 7:
  272. X                if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != NULL) {
  273. X                    param->esc_char = c;
  274. X                    ret_code++;
  275. X                }
  276. X                break;
  277. X            case 8:
  278. X                if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != NULL) {
  279. X                    param->brk_char = c;
  280. X                    ret_code++;
  281. X                }
  282. X            case 9:
  283. X                if ((ans = menu_prompt(g_win, 14, 50, "Aborted downloads", v_abort)) != NULL) {
  284. X                    free_ptr(param->abort);
  285. X                    param->abort = strdup(ans);
  286. X                    ret_code++;
  287. X                }
  288. X                break;
  289. X            case 10:
  290. X                if ((num = num_prompt(g_win, 16, 50, "Connect delay time", "(in seconds)")) != -1) {
  291. X                    if (num > MAX_CDELAY || num < MIN_CDELAY) {
  292. X                        beep();
  293. X                    /* some reasonable range of values */
  294. X                        if (num < MIN_CDELAY)
  295. X                            num = MIN_CDELAY;
  296. X                        else
  297. X                            num = MAX_CDELAY;
  298. X                        mvwaddstr(g_win, 16, 50, "   ");
  299. X                        wrefresh(g_win);
  300. X                        mvwattrnum(g_win, 16, 50, A_BOLD, num);
  301. X                        wrefresh(g_win);
  302. X                    }
  303. X                    param->c_delay = num;
  304. X                    ret_code++;
  305. X                }
  306. X                break;
  307. X            case 11:
  308. X                if ((num = num_prompt(g_win, 17, 50, "Redial delay time", "(in seconds)")) != -1) {
  309. X                    if (num > MAX_PAUSE || num < MIN_PAUSE) {
  310. X                        beep();
  311. X                    /* some reasonable range */
  312. X                        if (num < MIN_PAUSE)
  313. X                            num = MIN_PAUSE;
  314. X                        else
  315. X                            num = MAX_PAUSE;
  316. X                        mvwaddstr(g_win, 17, 50, "    ");
  317. X                        wrefresh(g_win);
  318. X                        mvwattrnum(g_win, 17, 50, A_BOLD, num);
  319. X                        wrefresh(g_win);
  320. X                    }
  321. X                    param->r_delay = num;
  322. X                    ret_code++;
  323. X                }
  324. X                break;
  325. X            default:
  326. X                beep();
  327. X        }
  328. X        mvwaddstr(g_win, 20, 12, "  ");
  329. X        clear_line(g_win, 21, 0, 0);
  330. X        clear_line(g_win, 22, 0, 0);
  331. X        wmove(g_win, 20, 12);
  332. X        wrefresh(g_win);
  333. X    }
  334. X    delwin(g_win);
  335. X    return(ret_code);
  336. X}
  337. SHAR_EOF
  338. if test 4457 -ne "`wc -c < 's_gen.c'`"
  339. then
  340.     echo shar: "error transmitting 's_gen.c'" '(should have been 4457 characters)'
  341. fi
  342. fi
  343. echo shar: "extracting 's_menu.c'" '(2732 characters)'
  344. if test -f 's_menu.c'
  345. then
  346.     echo shar: "will not over-write existing file 's_menu.c'"
  347. else
  348. sed 's/^X//' << \SHAR_EOF > 's_menu.c'
  349. X/*
  350. X * Display the setup menu, prompts for a bunch of other menus.  A return
  351. X * code of 1 means we have to restart the input routine.
  352. X */
  353. X
  354. X#include <stdio.h>
  355. X#include <curses.h>
  356. X#include "config.h"
  357. X#include "misc.h"
  358. X
  359. Xint
  360. Xsetup_menu()
  361. X{
  362. X    extern int fd, xmc;
  363. X    WINDOW *s_win, *newwin();
  364. X    char *ans, *get_str();
  365. X    int param_flag, modem_flag, ret_code;
  366. X    void top_line();
  367. X
  368. X    s_win = newwin(23, 80, 0, 0);
  369. X
  370. X    top_line(s_win);
  371. X    mvwaddstr(s_win, 4, 30, "1) TTY Setup");
  372. X    mvwaddstr(s_win, 6, 30, "2) Modem Setup");
  373. X    mvwaddstr(s_win, 8, 30, "3) Terminal Setup");
  374. X    mvwaddstr(s_win, 10, 30, "4) General Setup");
  375. X    mvwaddstr(s_win, 12, 30, "5) ASCII Transfer Setup");
  376. X    mvwaddstr(s_win, 14, 30, "S) Save setup to disk");
  377. X    horizontal(s_win, 19, 0, 80);
  378. X    mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  379. X    mvwaddstr(s_win, 20, 58, "  Press <ESC> to exit");
  380. X    wmove(s_win, 20, 12);
  381. X    touchwin(s_win);
  382. X    wrefresh(s_win);
  383. X
  384. X    param_flag = 0;
  385. X    modem_flag = 0;
  386. X    ret_code = 0;
  387. X                    /* get the options */
  388. X    while ((ans = get_str(s_win, 1, "12345Ss", "")) != NULL) {
  389. X        if (xmc > 0) {
  390. X            clear_line(s_win, 0, 0, 0);
  391. X            wrefresh(s_win);
  392. X        }
  393. X        switch (*ans) {
  394. X            case '1':
  395. X                if (tty_setup())
  396. X                    modem_flag++;
  397. X                break;
  398. X            case '2':
  399. X                if (modem_setup())
  400. X                    modem_flag++;
  401. X                break;
  402. X            case '3':
  403. X                if (ret_code = term_setup()) {
  404. X                    ret_code--;
  405. X                    param_flag++;
  406. X                }
  407. X                break;
  408. X            case '4':
  409. X                if (gen_setup())
  410. X                    param_flag++;
  411. X                break;
  412. X            case '5':
  413. X                if (axfer_setup())
  414. X                    param_flag++;
  415. X                break;
  416. X            case 's':
  417. X            case 'S':
  418. X                if (xmc > 0)
  419. X                    top_line(s_win);
  420. X                if (param_flag || modem_flag) {
  421. X                    wmove(s_win, 22, 27);
  422. X                    /*
  423. X                     * Writes to disk are not critical,
  424. X                     * the changes are made in memory.
  425. X                     */
  426. X                    if (param_flag) {
  427. X                        wattrstr(s_win, A_BLINK, "Updating Parameter File");
  428. X                        wrefresh(s_win);
  429. X                        wait_key(s_win, 3);
  430. X                        if (up_param()) {
  431. X                            touchwin(s_win);
  432. X                            wrefresh(s_win);
  433. X                        }
  434. X                    }
  435. X                    if (modem_flag) {
  436. X                        wattrstr(s_win, A_BLINK, "Updating Modem Database");
  437. X                        wrefresh(s_win);
  438. X                        wait_key(s_win, 3);
  439. X                        if (up_modem()) {
  440. X                            touchwin(s_win);
  441. X                            wrefresh(s_win);
  442. X                        }
  443. X                    }
  444. X                    clear_line(s_win, 22, 27, 0);
  445. X                    wrefresh(s_win);
  446. X                }
  447. X                break;
  448. X            default:
  449. X                beep();
  450. X        }
  451. X        touchwin(s_win);
  452. X        if (xmc > 0)
  453. X            top_line(s_win);
  454. X
  455. X        mvwaddch(s_win, 20, 12, (chtype) ' ');
  456. X        wmove(s_win, 20, 12);
  457. X        wrefresh(s_win);
  458. X    }
  459. X    if (fd == -1) {
  460. X        werase(s_win);
  461. X        wrefresh(s_win);
  462. X    }
  463. X    delwin(s_win);
  464. X    return(ret_code);
  465. X}
  466. X
  467. X/*
  468. X * Put the top line on the window.
  469. X */
  470. X
  471. Xvoid
  472. Xtop_line(win)
  473. XWINDOW *win;
  474. X{
  475. X    clear_line(win, 0, 0, 0);
  476. X    wrefresh(win);
  477. X    horizontal(win, 0, 0, 33);
  478. X    mvwattrstr(win, 0, 34, A_BOLD, "Setup Menu");
  479. X    horizontal(win, 0, 45, 34);
  480. X    wrefresh(win);
  481. X    return;
  482. X}
  483. SHAR_EOF
  484. if test 2732 -ne "`wc -c < 's_menu.c'`"
  485. then
  486.     echo shar: "error transmitting 's_menu.c'" '(should have been 2732 characters)'
  487. fi
  488. fi
  489. echo shar: "extracting 's_modem.c'" '(6867 characters)'
  490. if test -f 's_modem.c'
  491. then
  492.     echo shar: "will not over-write existing file 's_modem.c'"
  493. else
  494. sed 's/^X//' << \SHAR_EOF > 's_modem.c'
  495. X/*
  496. X * Display the modem setup, query for changes.  A return code of 1 means
  497. X * something was changed.
  498. X */
  499. X
  500. X#include <stdio.h>
  501. X#include <curses.h>
  502. X#include "config.h"
  503. X#include "misc.h"
  504. X#include "modem.h"
  505. X
  506. Xint
  507. Xmodem_setup()
  508. X{
  509. X    WINDOW *mo_win, *newwin();
  510. X    int i, j, ret_code, mod_prompt();
  511. X    char *ans, *strdup(), *str_prompt(), *menu_prompt();
  512. X    void disp_modem(), free_ptr();
  513. X    static char *v_yn[3] = {"Y", "N", NULL};
  514. X                    /* the current modem */
  515. X    j = 0;
  516. X    if (modem->m_cur != -1)
  517. X        j = modem->m_cur;
  518. X
  519. X    mo_win = newwin(23, 80, 0, 0);
  520. X
  521. X    horizontal(mo_win, 0, 0, 33);
  522. X    mvwattrstr(mo_win, 0, 34, A_BOLD, "Modem Setup");
  523. X    horizontal(mo_win, 0, 46, 34);
  524. X                    /* display the current settings */
  525. X    disp_modem(mo_win, j);
  526. X    horizontal(mo_win, 19, 0, 80);
  527. X    mvwattrstr(mo_win, 20, 0, A_BOLD, "OPTION ==> ");
  528. X    mvwaddstr(mo_win, 20, 58, "Press <ESC> to return");
  529. X    wmove(mo_win, 20, 12);
  530. X    touchwin(mo_win);
  531. X    wrefresh(mo_win);
  532. X                    /* get the option number */
  533. X    ret_code = 0;
  534. X    while ((i = get_num(mo_win, 2)) != -1) {
  535. X        switch (i) {
  536. X            case 1:
  537. X                j = mod_prompt(mo_win);
  538. X                break;
  539. X            case 2:
  540. X                if ((ans = str_prompt(mo_win, 3, 40, "Modem init string", "sent to the modem once")) != NULL) {
  541. X                    free_ptr(modem->init[j]);
  542. X                    modem->init[j] = strdup(ans);
  543. X                    ret_code++;
  544. X                }
  545. X                break;
  546. X            case 3:
  547. X                if ((ans = str_prompt(mo_win, 4, 40, "Dialing command", "")) != NULL) {
  548. X                    free_ptr(modem->dial[j]);
  549. X                    modem->dial[j] = strdup(ans);
  550. X                    ret_code++;
  551. X                }
  552. X                break;
  553. X            case 4:
  554. X                if ((ans = str_prompt(mo_win, 5, 40, "Dialing cmd suffix", "typically the <CR> character")) != NULL) {
  555. X                    free_ptr(modem->suffix[j]);
  556. X                    modem->suffix[j] = strdup(ans);
  557. X                    ret_code++;
  558. X                }
  559. X                break;
  560. X            case 5:
  561. X                if ((ans = str_prompt(mo_win, 6, 40, "Hang up string", "")) != NULL) {
  562. X                    free_ptr(modem->hang_up[j]);
  563. X                    modem->hang_up[j] = strdup(ans);
  564. X                    ret_code++;
  565. X                }
  566. X                break;
  567. X            case 6:
  568. X                if ((ans = menu_prompt(mo_win, 7, 40, "Auto Baud detect", v_yn)) != NULL) {
  569. X                    modem->auto_baud[j] = *ans;
  570. X                    ret_code++;
  571. X                }
  572. X                break;
  573. X            case 7:
  574. X                if ((ans = str_prompt(mo_win, 8, 40, "300 baud connect string", "")) != NULL) {
  575. X                    free_ptr(modem->con_3[j]);
  576. X                    modem->con_3[j] = strdup(ans);
  577. X                    ret_code++;
  578. X                }
  579. X                break;
  580. X            case 8:
  581. X                if ((ans = str_prompt(mo_win, 9, 40, "1200 baud connect string", "")) != NULL) {
  582. X                    free_ptr(modem->con_12[j]);
  583. X                    modem->con_12[j] = strdup(ans);
  584. X                    ret_code++;
  585. X                }
  586. X                break;
  587. X            case 9:
  588. X                if ((ans = str_prompt(mo_win, 10, 40, "2400 baud connect string", "")) != NULL) {
  589. X                    free_ptr(modem->con_24[j]);
  590. X                    modem->con_24[j] = strdup(ans);
  591. X                    ret_code++;
  592. X                }
  593. X                break;
  594. X            case 10:
  595. X                if ((ans = str_prompt(mo_win, 11, 40, "4800 baud connect string", "")) != NULL) {
  596. X                    free_ptr(modem->con_48[j]);
  597. X                    modem->con_48[j] = strdup(ans);
  598. X                    ret_code++;
  599. X                }
  600. X                break;
  601. X            case 11:
  602. X                if ((ans = str_prompt(mo_win, 12, 40, "9600 baud connect string", "")) != NULL) {
  603. X                    free_ptr(modem->con_96[j]);
  604. X                    modem->con_96[j] = strdup(ans);
  605. X                    ret_code++;
  606. X                }
  607. X                break;
  608. X            case 12:
  609. X                if ((ans = str_prompt(mo_win, 13, 40, "19200 baud connect string", "")) != NULL) {
  610. X                    free_ptr(modem->con_192[j]);
  611. X                    modem->con_192[j] = strdup(ans);
  612. X                    ret_code++;
  613. X                }
  614. X                break;
  615. X            case 13:
  616. X                if ((ans = str_prompt(mo_win, 14, 40, "No connect string 1", "")) != NULL) {
  617. X                    free_ptr(modem->no_con1[j]);
  618. X                    modem->no_con1[j] = strdup(ans);
  619. X                    ret_code++;
  620. X                }
  621. X                break;
  622. X            case 14:
  623. X                if ((ans = str_prompt(mo_win, 15, 40, "No connect string 2", "")) != NULL) {
  624. X                    free_ptr(modem->no_con2[j]);
  625. X                    modem->no_con2[j] = strdup(ans);
  626. X                    ret_code++;
  627. X                }
  628. X                break;
  629. X            case 15:
  630. X                if ((ans = str_prompt(mo_win, 16, 40, "No connect string 3", "")) != NULL) {
  631. X                    free_ptr(modem->no_con3[j]);
  632. X                    modem->no_con3[j] = strdup(ans);
  633. X                    ret_code++;
  634. X                }
  635. X                break;
  636. X            case 16:
  637. X                if ((ans = str_prompt(mo_win, 17, 40, "No connect string 4", "")) != NULL) {
  638. X                    free_ptr(modem->no_con4[j]);
  639. X                    modem->no_con4[j] = strdup(ans);
  640. X                    ret_code++;
  641. X                }
  642. X                break;
  643. X            default:
  644. X                beep();
  645. X        }
  646. X                    /* clear the previous prompts */
  647. X        mvwaddstr(mo_win, 20, 12, "   ");
  648. X        clear_line(mo_win, 21, 0, 0);
  649. X        clear_line(mo_win, 22, 0, 0);
  650. X        wmove(mo_win, 20, 12);
  651. X        wrefresh(mo_win);
  652. X    }
  653. X    delwin(mo_win);
  654. X    return(ret_code);
  655. X}
  656. X
  657. X/*
  658. X * Prompts for the modem name.  The user selects the currently showing
  659. X * choice by hitting a carriage return.  Returns the modem entry number.
  660. X * DOES NOT change the value of modem->m_cur.
  661. X */
  662. X
  663. Xstatic int
  664. Xmod_prompt(win)
  665. XWINDOW *win;
  666. X{
  667. X    char ans;
  668. X    int i;
  669. X                    /* print prompt lines */
  670. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  671. X    mvwaddstr(win, 21, 0, "Modem name: ");
  672. X                    /* show current choice */
  673. X    i = 0;
  674. X    if (modem->m_cur != -1)
  675. X        i = modem->m_cur;
  676. X    mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  677. X    wmove(win, 21, 12);
  678. X    wrefresh(win);
  679. X                    /* show the choices one at a time */
  680. X    while ((ans = wgetch(win)) != '\r') {
  681. X        i++;
  682. X        if (*modem->mname[i] == NULL)
  683. X            i = 0;
  684. X        if (ans == ESC)
  685. X            return(0);
  686. X        mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  687. X        wmove(win, 21, 12);
  688. X        wrefresh(win);
  689. X    }
  690. X                    /* display the new values */
  691. X    disp_modem(win, i);
  692. X                    /* display the name in bold */
  693. X    clear_line(win, 2, 40, 0);
  694. X    wrefresh(win);
  695. X    mvwattrstr(win, 2, 40, A_BOLD, modem->mname[i]);
  696. X    mvwprintw(win, 2, 26, "(%d of %d) ", i+1, modem->m_entries);
  697. X
  698. X    return(i);
  699. X}
  700. X
  701. X/*
  702. X * Show the current settings for the given modem entry number.
  703. X */
  704. X
  705. Xstatic void
  706. Xdisp_modem(w, i)
  707. XWINDOW *w;
  708. Xint i;
  709. X{
  710. X    mvwprintw(w, 2, 12, "1) Modem name ............. %-39.39s", modem->mname[i]);
  711. X    mvwprintw(w, 2, 26, "(%d of %d) ", i+1, modem->m_entries);
  712. X    mvwprintw(w, 3, 12, "2) Modem init string ...... %-39.39s", modem->init[i]);
  713. X    mvwprintw(w, 4, 12, "3) Dialing command ........ %-39.39s", modem->dial[i]);
  714. X    mvwprintw(w, 5, 12, "4) Dialing cmd suffix ..... %-39.39s", modem->suffix[i]);
  715. X    mvwprintw(w, 6, 12, "5) Hang up string ......... %-39.39s", modem->hang_up[i]);
  716. X    mvwprintw(w, 7, 12, "6) Auto baud detect ....... %c", modem->auto_baud[i]);
  717. X    mvwprintw(w, 8, 12, "7) 300 baud connect ....... %-39.39s", modem->con_3[i]);
  718. X    mvwprintw(w, 9, 12, "8) 1200 baud connect ...... %-39.39s", modem->con_12[i]);
  719. X    mvwprintw(w, 10, 12, "9) 2400 baud connect ...... %-39.39s", modem->con_24[i]);
  720. X    mvwprintw(w, 11, 11, "10) 4800 baud connect ...... %-39.39s", modem->con_48[i]);
  721. X    mvwprintw(w, 12, 11, "11) 9600 baud connect ...... %-39.39s", modem->con_96[i]);
  722. X    mvwprintw(w, 13, 11, "12) 19200 baud connect ..... %-39.39s", modem->con_192[i]);
  723. X    mvwprintw(w, 14, 11, "13) No connect string 1 .... %-39.39s", modem->no_con1[i]);
  724. X    mvwprintw(w, 15, 11, "14) No connect string 2 .... %-39.39s", modem->no_con2[i]);
  725. X    mvwprintw(w, 16, 11, "15) No connect string 3 .... %-39.39s", modem->no_con3[i]);
  726. X    mvwprintw(w, 17, 11, "16) No connect string 4 .... %-39.39s", modem->no_con4[i]);
  727. X    return;
  728. X}
  729. SHAR_EOF
  730. if test 6867 -ne "`wc -c < 's_modem.c'`"
  731. then
  732.     echo shar: "error transmitting 's_modem.c'" '(should have been 6867 characters)'
  733. fi
  734. fi
  735. echo shar: "extracting 's_prompt.c'" '(2972 characters)'
  736. if test -f 's_prompt.c'
  737. then
  738.     echo shar: "will not over-write existing file 's_prompt.c'"
  739. else
  740. sed 's/^X//' << \SHAR_EOF > 's_prompt.c'
  741. X/*
  742. X * Prompting routines used in the setup menus.
  743. X */
  744. X
  745. X#include <stdio.h>
  746. X#include <curses.h>
  747. X#include "config.h"
  748. X#include "misc.h"
  749. X
  750. X/*
  751. X * Prompt for a string at line 21 (with optional line 22 for additional
  752. X * information).  Display the new string in bold at its original location
  753. X * in the menu.  Used in virtually all of the *_setup() routines.
  754. X */
  755. X
  756. Xchar *
  757. Xstr_prompt(win, y, x, p1, p2)
  758. XWINDOW *win;
  759. Xint y, x;
  760. Xchar *p1, *p2;
  761. X{
  762. X    extern char *null_ptr;
  763. X    char *ans, *get_str();
  764. X                    /* print first prompt last */
  765. X    mvwaddstr(win, 22, 0, p2);
  766. X    mvwaddstr(win, 21, 0, p1);
  767. X    waddstr(win, ": ");
  768. X    wrefresh(win);
  769. X
  770. X    if ((ans = get_str(win, 39, "", "")) == NULL)
  771. X        return(NULL);
  772. X                    /* check the value */
  773. X    if (!strcmp(ans, " "))
  774. X        ans = null_ptr;
  775. X                    /* display the value in bold */
  776. X    clear_line(win, y, x, 0);
  777. X    wattrstr(win, A_BOLD, ans);
  778. X
  779. X    return(ans);
  780. X}
  781. X
  782. X/*
  783. X * Same as above, except we return a single character.
  784. X */
  785. X
  786. Xchar
  787. Xchr_prompt(win, y, x, p1, p2)
  788. XWINDOW *win;
  789. Xint y, x;
  790. Xchar *p1, *p2;
  791. X{
  792. X    char *ans, *get_str();
  793. X                    /* print first prompt last */
  794. X    mvwaddstr(win, 22, 0, p2);
  795. X    mvwaddstr(win, 21, 0, p1);
  796. X    waddstr(win, ": ");
  797. X    wrefresh(win);
  798. X
  799. X    if ((ans = get_str(win, 1, "", "")) == NULL)
  800. X        return(NULL);
  801. X                    /* display the value in bold */
  802. X    mvwaddstr(win, y, x, "  ");
  803. X    wrefresh(win);
  804. X    mvwattrstr(win, y, x, A_BOLD, ans);
  805. X
  806. X    return(*ans);
  807. X}
  808. X
  809. X/*
  810. X * Same as above, except that it prompts for a three digit number.
  811. X */
  812. X
  813. Xint
  814. Xnum_prompt(win, y, x, p1, p2)
  815. XWINDOW *win;
  816. Xint y, x;
  817. Xchar *p1, *p2;
  818. X{
  819. X    int i;
  820. X                    /* print first prompt last */
  821. X    mvwaddstr(win, 22, 0, p2);
  822. X    mvwaddstr(win, 21, 0, p1);
  823. X    waddstr(win, ": ");
  824. X    wrefresh(win);
  825. X
  826. X    if ((i = get_num(win, 3)) == -1)
  827. X        return(-1);
  828. X                    /* display the value in bold */
  829. X    mvwaddstr(win, y, x, "    ");
  830. X    wrefresh(win);
  831. X    mvwattrnum(win, y, x, A_BOLD, i);
  832. X                    /* return the number */
  833. X    return(i);
  834. X}
  835. X
  836. X/*
  837. X * Prompts for a selection from a menu.  We display the prompt lines,
  838. X * and show the choices one at a time.  The user selects the currently
  839. X * showing choice by hitting a carriage return.  Unlike the similar
  840. X * routines in d_prompt(), the first choice shown is not necessarily
  841. X * the current.
  842. X */
  843. X
  844. Xchar *v_yes[3] = {"YES", "NO", NULL};
  845. X
  846. Xchar *
  847. Xmenu_prompt(win, y, x, p, menu)
  848. XWINDOW *win;
  849. Xint y, x;
  850. Xchar *p, *menu[];
  851. X{
  852. X    char ans;
  853. X    int i, cy, cx;
  854. X                    /* print first prompt last */
  855. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  856. X    mvwaddstr(win, 21, 0, p);
  857. X    waddstr(win, ": ");
  858. X                    /* show first choice */
  859. X    i = 0;
  860. X    getyx(win, cy, cx);
  861. X    mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  862. X    wmove(win, cy, cx);
  863. X    wrefresh(win);
  864. X                    /* show the choices one at a time */
  865. X    while ((ans = wgetch(win)) != '\r') {
  866. X        i++;
  867. X        if (menu[i] == NULL)
  868. X            i = 0;
  869. X        if (ans == ESC)
  870. X            return(NULL);
  871. X        mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  872. X        wmove(win, cy, cx);
  873. X        wrefresh(win);
  874. X    }
  875. X                    /* display the value in bold */
  876. X    clear_line(win, y, x, 0);
  877. X    wattrstr(win, A_BOLD, menu[i]);
  878. X                    /* return the value */
  879. X    return(menu[i]);
  880. X}
  881. SHAR_EOF
  882. if test 2972 -ne "`wc -c < 's_prompt.c'`"
  883. then
  884.     echo shar: "error transmitting 's_prompt.c'" '(should have been 2972 characters)'
  885. fi
  886. fi
  887. echo shar: "extracting 's_term.c'" '(3172 characters)'
  888. if test -f 's_term.c'
  889. then
  890.     echo shar: "will not over-write existing file 's_term.c'"
  891. else
  892. sed 's/^X//' << \SHAR_EOF > 's_term.c'
  893. X/*
  894. X * Display the terminal setup, query for changes.  A return code of 1
  895. X * means something was changed, 2 means we have to kill and restart
  896. X * the input routine.
  897. X */
  898. X
  899. X#include <stdio.h>
  900. X#include <curses.h>
  901. X#include "config.h"
  902. X#include "misc.h"
  903. X#include "param.h"
  904. X#include "status.h"
  905. X
  906. Xint
  907. Xterm_setup()
  908. X{
  909. X    WINDOW *t_win, *newwin();
  910. X    int i, num, ret_code;
  911. X    char *ans, *strdup(), *str_prompt(), *menu_prompt();
  912. X    void free_ptr(), input_off(), line_set();
  913. X    static char *v_crio[3] = {"CR", "CR/LF", NULL};
  914. X    static char *v_duplex[3] = {"FULL", "HALF", NULL};
  915. X    static char *v_flow[3] = {"NONE", "XON/XOFF", NULL};
  916. X
  917. X    t_win = newwin(23, 80, 0, 0);
  918. X
  919. X    horizontal(t_win, 0, 0, 32);
  920. X    mvwattrstr(t_win, 0, 33, A_BOLD, "Terminal Setup");
  921. X    horizontal(t_win, 0, 48, 32);
  922. X    mvwprintw(t_win, 4, 22, "1) Hot key (decimal) ...... %d", param->hot);
  923. X    mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  924. X    mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  925. X    mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
  926. X    mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  927. X    mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  928. X    horizontal(t_win, 19, 0, 80);
  929. X    mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  930. X    mvwaddstr(t_win, 20, 58, "Press <ESC> to return");
  931. X    wmove(t_win, 20, 12);
  932. X    touchwin(t_win);
  933. X    wrefresh(t_win);
  934. X                    /* get the option number */
  935. X    ret_code = 0;
  936. X    while ((i = get_num(t_win, 1)) != -1) {
  937. X        switch (i) {
  938. X            case 1:
  939. X                if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  940. X                    param->hot = num;
  941. X                    ret_code = 1;
  942. X                }
  943. X                break;
  944. X            case 2:
  945. X                if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
  946. X                    free_ptr(param->ascii_hot);
  947. X                    param->ascii_hot = strdup(ans);
  948. X                    ret_code = 1;
  949. X                }
  950. X                break;
  951. X            case 3:
  952. X                if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL ) {
  953. X                    free_ptr(param->d_duplex);
  954. X                    param->d_duplex = strdup(ans);
  955. X                    ret_code = 1;
  956. X                }
  957. X                break;
  958. X            case 4:
  959. X                if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL ) {
  960. X                    free_ptr(param->flow);
  961. X                    param->flow = strdup(ans);
  962. X                    line_set();
  963. X                    ret_code = 1;
  964. X                }
  965. X                break;
  966. X            case 5:
  967. X                if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL ) {
  968. X                    free_ptr(param->cr_in);
  969. X
  970. X                    /*
  971. X                     * the "add lf to cr" function is
  972. X                     * performed by the input routine
  973. X                     */
  974. X                    param->cr_in = strdup(ans);
  975. X                    if (!strcmp(ans, "CR/LF"))
  976. X                        status->add_lf = 1;
  977. X                    else
  978. X                        status->add_lf = 0;
  979. X#ifdef SHAREDMEM
  980. X                    ret_code = 1;
  981. X#else /* SHAREDMEM */
  982. X                    input_off();
  983. X                    ret_code = 2;
  984. X#endif /* SHAREDMEM */
  985. X                }
  986. X                break;
  987. X            case 6:
  988. X                if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL ) {
  989. X                    free_ptr(param->cr_out);
  990. X                    param->cr_out = strdup(ans);
  991. X                    ret_code = 1;
  992. X                }
  993. X                break;
  994. X            default:
  995. X                beep();
  996. X        }
  997. X        mvwaddch(t_win, 20, 12, (chtype) ' ');
  998. X        clear_line(t_win, 21, 0, 0);
  999. X        clear_line(t_win, 22, 0, 0);
  1000. X        wmove(t_win, 20, 12);
  1001. X        wrefresh(t_win);
  1002. X    }
  1003. X    delwin(t_win);
  1004. X    return(ret_code);
  1005. X}
  1006. SHAR_EOF
  1007. if test 3172 -ne "`wc -c < 's_term.c'`"
  1008. then
  1009.     echo shar: "error transmitting 's_term.c'" '(should have been 3172 characters)'
  1010. fi
  1011. fi
  1012. echo shar: "extracting 's_tty.c'" '(4800 characters)'
  1013. if test -f 's_tty.c'
  1014. then
  1015.     echo shar: "will not over-write existing file 's_tty.c'"
  1016. else
  1017. sed 's/^X//' << \SHAR_EOF > 's_tty.c'
  1018. X/*
  1019. X * Display the TTY setup, query for changes.  A return code of 1
  1020. X * means something was changed.
  1021. X */
  1022. X
  1023. X#include <stdio.h>
  1024. X#include <curses.h>
  1025. X#include "config.h"
  1026. X#include "misc.h"
  1027. X#include "modem.h"
  1028. X
  1029. Xint
  1030. Xtty_setup()
  1031. X{
  1032. X    extern char *null_ptr;
  1033. X    WINDOW *tt_win, *newwin();
  1034. X    char *strdup(), message[80];
  1035. X    int num, i, j, ret_code;
  1036. X    void disp_tty(), create_modem(), del_modem(), error_win();
  1037. X    void del_tty();
  1038. X
  1039. X    tt_win = newwin(23, 80, 0, 0);
  1040. X
  1041. X    horizontal(tt_win, 0, 0, 34);
  1042. X    mvwattrstr(tt_win, 0, 35, A_BOLD, "TTY Setup");
  1043. X    horizontal(tt_win, 0, 45, 34);
  1044. X    mvwaddstr(tt_win, 2, 22, "TTY name");
  1045. X    mvwaddstr(tt_win, 2, 37, "Modem name");
  1046. X    mvwaddstr(tt_win, 2, 51, "Init speed");
  1047. X                    /* display the current TTY list */
  1048. X    disp_tty(tt_win);
  1049. X                    /* prompt for options */
  1050. X    mvwprintw(tt_win, 15, 20, "%d) Add a TTY entry", NUM_TTY+1);
  1051. X    mvwprintw(tt_win, 16, 20, "%d) Delete a TTY entry", NUM_TTY+2);
  1052. X    horizontal(tt_win, 19, 0, 80);
  1053. X    mvwattrstr(tt_win, 20, 0, A_BOLD, "OPTION ==> ");
  1054. X    mvwaddstr(tt_win, 20, 58, "Press <ESC> to return");
  1055. X    wmove(tt_win, 20, 12);
  1056. X    touchwin(tt_win);
  1057. X    wrefresh(tt_win);
  1058. X                    /* get the option number */
  1059. X    ret_code = 0;
  1060. X    while ((i = get_num(tt_win, 2)) != -1) {
  1061. X                    /* if beyond t_entries, fake it */
  1062. X        if (i > modem->t_entries && i <= NUM_TTY)
  1063. X            i=999;
  1064. X                    /* change an entry  */
  1065. X        if (i >= 1 && i <= NUM_TTY) {
  1066. X            if (tty_prompt(tt_win, i-1))
  1067. X                break;
  1068. X                    /* requires modem update? */
  1069. X            create_modem(modem->tname[i-1]);
  1070. X            del_modem();
  1071. X
  1072. X            ret_code++;
  1073. X        }
  1074. X                    /* add a entry */
  1075. X        if (i == NUM_TTY+1) {
  1076. X            if (modem->t_entries == NUM_TTY) {
  1077. X                sprintf(message, "'%s'", modem->m_path);
  1078. X                error_win(0, "No empty TTY slots in modem/TTY database", message);
  1079. X                continue;
  1080. X            }
  1081. X                    /* prompt for info */
  1082. X            j = modem->t_entries;
  1083. X            if (tty_prompt(tt_win, j))
  1084. X                break;
  1085. X                    /* add modem entry? */
  1086. X            modem->t_entries++;
  1087. X            create_modem(modem->tname[j]);
  1088. X
  1089. X            ret_code++;
  1090. X        }
  1091. X                    /* delete an entry */
  1092. X        if (i == NUM_TTY+2) {
  1093. X            mvwaddstr(tt_win, 21, 0, "Entry number to delete: ");
  1094. X            wrefresh(tt_win);
  1095. X            while ((num = get_num(tt_win, 4)) != -1) {
  1096. X                    /* valid range */
  1097. X                if (!num || num>modem->t_entries) {
  1098. X                    beep();
  1099. X                    mvwaddstr(tt_win, 21, 24, "   ");
  1100. X                    wmove(tt_win, 21, 24);
  1101. X                    wrefresh(tt_win);
  1102. X                    continue;
  1103. X                }
  1104. X                del_tty(num-1);
  1105. X                del_modem();
  1106. X
  1107. X                    /* show the new list */
  1108. X                disp_tty(tt_win);
  1109. X                ret_code++;
  1110. X                break;
  1111. X            }
  1112. X        }
  1113. X        if (i == 0 || i>NUM_TTY+2)
  1114. X            beep();
  1115. X        mvwaddstr(tt_win, 20, 12, "  ");
  1116. X        clear_line(tt_win, 21, 0, 0);
  1117. X        clear_line(tt_win, 22, 0, 0);
  1118. X        wmove(tt_win, 20, 12);
  1119. X        wrefresh(tt_win);
  1120. X    }
  1121. X    delwin(tt_win);
  1122. X    return(ret_code);
  1123. X}
  1124. X
  1125. X/*
  1126. X * Display the current TTY list.  No scrolling yet, so if your NUM_TTY is
  1127. X * greater than ten, this routine will need some work.
  1128. X */
  1129. X
  1130. Xstatic void
  1131. Xdisp_tty(win)
  1132. XWINDOW *win;
  1133. X{
  1134. X    int i;
  1135. X
  1136. X    for (i=0; i<NUM_TTY; i++)
  1137. X        mvwprintw(win, i+4, 20, "%2d) %-14.14s %-14.14s  %d\n",
  1138. X         i+1, modem->tty[i], modem->tname[i], modem->init_sp[i]);
  1139. X    return;
  1140. X}
  1141. X
  1142. X/*
  1143. X * Prompt the user for the TTY database info.  A return code of 1 means a
  1144. X * user abort.  The second argument is the zero based index.
  1145. X */
  1146. X
  1147. Xstatic int
  1148. Xtty_prompt(win, i)
  1149. XWINDOW *win;
  1150. Xint i;
  1151. X{
  1152. X    char *ans, *temp_tty, *temp_tname, *str_prompt(), *menu_prompt();
  1153. X    void free_ptr();
  1154. X    static char *v_baud[8] = {"0", "300", "1200", "2400", "4800", "9600",
  1155. X     "19200", NULL};
  1156. X                    /* get temp TTY */
  1157. X    if ((ans = str_prompt(win, i+4, 24, "TTY name", "")) == NULL)
  1158. X        return(1);
  1159. X
  1160. X    temp_tty = strdup(ans);
  1161. X    clear_line(win, 21, 0, 0);
  1162. X
  1163. X                    /* get temp tname */
  1164. X    if ((ans = str_prompt(win, i+4, 39, "Modem name", "")) == NULL)
  1165. X        return(1);
  1166. X
  1167. X    temp_tname = strdup(ans);
  1168. X    clear_line(win, 21, 0, 0);
  1169. X
  1170. X                    /* get maximum baud */
  1171. X    if ((ans = menu_prompt(win, i+4, 55, "Init speed", v_baud)) == NULL)
  1172. X        return(1);
  1173. X
  1174. X    wrefresh(win);
  1175. X                    /* store 'em for real */
  1176. X    free_ptr(modem->tty[i]);
  1177. X    free_ptr(modem->tname[i]);
  1178. X
  1179. X    modem->tty[i] = strdup(temp_tty);
  1180. X    modem->tname[i] = strdup(temp_tname);
  1181. X    modem->init_sp[i] = atoi(ans);
  1182. X
  1183. X    free_ptr(temp_tty);
  1184. X    free_ptr(temp_tname);
  1185. X    return(0);
  1186. X}
  1187. X
  1188. X/*
  1189. X * Delete a TTY entry.  Since the list must be contiguous, we collapse the
  1190. X * list to cover the hole we made.
  1191. X */
  1192. X
  1193. Xstatic void
  1194. Xdel_tty(i)
  1195. Xint i;
  1196. X{
  1197. X    extern char *null_ptr;
  1198. X    int j;
  1199. X    char *strdup();
  1200. X    void free_ptr();
  1201. X                    /* collapse the list */
  1202. X    for (j=i; j<modem->t_entries-1; j++) {
  1203. X        free_ptr(modem->tty[j]);
  1204. X        free_ptr(modem->tname[j]);
  1205. X        modem->tty[j] = strdup(modem->tty[j+1]);
  1206. X        modem->tname[j] = strdup(modem->tname[j+1]);
  1207. X        modem->init_sp[j] = modem->init_sp[j+1];
  1208. X    }
  1209. X    j = modem->t_entries-1;
  1210. X                    /* zap the entry */
  1211. X    free_ptr(modem->tty[j]);
  1212. X    free_ptr(modem->tname[j]);
  1213. X    modem->tty[j] = null_ptr;
  1214. X    modem->tname[j] = null_ptr;
  1215. X    modem->init_sp[j] = 0;
  1216. X                    /* update the count */
  1217. X    modem->t_entries--;
  1218. X    if (modem->t_cur >= modem->t_entries)
  1219. X        modem->t_cur = -1;
  1220. X    return;
  1221. X}
  1222. SHAR_EOF
  1223. if test 4800 -ne "`wc -c < 's_tty.c'`"
  1224. then
  1225.     echo shar: "error transmitting 's_tty.c'" '(should have been 4800 characters)'
  1226. fi
  1227. fi
  1228. echo shar: "extracting 'screen.c'" '(2074 characters)'
  1229. if test -f 'screen.c'
  1230. then
  1231.     echo shar: "will not over-write existing file 'screen.c'"
  1232. else
  1233. sed 's/^X//' << \SHAR_EOF > 'screen.c'
  1234. X/*
  1235. X * Routines to read and copy the virtual screen image file.
  1236. X */
  1237. X
  1238. X#include <stdio.h>
  1239. X#include <curses.h>
  1240. X#include "config.h"
  1241. X#include "param.h"
  1242. X#include "status.h"
  1243. X
  1244. X/*
  1245. X * Do a screen dump.  Actually, the screen is already dumped, all we
  1246. X * do is copy the file.
  1247. X */
  1248. X
  1249. Xvoid
  1250. Xscreen_dump()
  1251. X{
  1252. X    FILE *fp_out, *my_fopen();
  1253. X    char buf[MAX_COL+2];
  1254. X    void error_win();
  1255. X#ifdef SHAREDMEM
  1256. X    int i;
  1257. X#else /* SHAREDMEM */
  1258. X    FILE *fp_in;
  1259. X#endif /* SHAREDMEM */
  1260. X                    /* open for append */
  1261. X    if (!(fp_out = my_fopen(param->dumpfile, "a"))) {
  1262. X        sprintf(buf, "'%s' for write", param->dumpfile);
  1263. X        error_win(0, "Can't open screen dump file", buf);
  1264. X        return;
  1265. X    }
  1266. X#ifdef SHAREDMEM
  1267. X    for (i=0; i<LINES; i++)
  1268. X        fprintf(fp_out, "%s\n", status->vs[i]);
  1269. X
  1270. X#else /* SHAREDMEM */
  1271. X                    /* not guaranteed to exist yet */
  1272. X    if (!(fp_in = my_fopen(status->vs_path, "r"))) {
  1273. X        fclose(fp_in);
  1274. X        return;
  1275. X    }
  1276. X                    /* skip the x, y coordinates */
  1277. X    fgets(buf, 10, fp_in);
  1278. X
  1279. X    while (fgets(buf, MAX_COL+2, fp_in) != NULL)
  1280. X        fputs(buf, fp_out);
  1281. X
  1282. X    fclose(fp_in);
  1283. X#endif /* SHAREDMEM */
  1284. X    fclose(fp_out);
  1285. X
  1286. X    return;
  1287. X}
  1288. X
  1289. X/*
  1290. X * Read the virtual screen and paint its contents to the stdscr using
  1291. X * curses(3).  Move the cursor where it belongs.
  1292. X */
  1293. X
  1294. Xvoid
  1295. Xload_vs()
  1296. X{
  1297. X    register int i;
  1298. X#ifndef SHAREDMEM
  1299. X    FILE *fp, *my_fopen();
  1300. X    int row, col;
  1301. X    char buf[MAX_COL+2];
  1302. X#endif /* SHAREDMEM */
  1303. X
  1304. X    clearok(curscr, TRUE);
  1305. X    erase();
  1306. X#ifdef SHAREDMEM
  1307. X    for (i=0; i<LINES; i++)
  1308. X        mvaddstr(i, 0, status->vs[i]);
  1309. X
  1310. X    move(status->row, status->col);
  1311. X#else /* SHAREDMEM */
  1312. X                    /* not guaranteed to exist yet */
  1313. X    if (!(fp = my_fopen(status->vs_path, "r")))
  1314. X        return;
  1315. X                    /* get the x, y coordinates */
  1316. X    fgets(buf, 10, fp);
  1317. X    sscanf(buf, "%d,%d\n", &row, &col);
  1318. X
  1319. X    i = 0;
  1320. X    while (fgets(buf, MAX_COL+2, fp) != NULL) {
  1321. X                    /* zap the line feed */
  1322. X        buf[COLS] = NULL;
  1323. X        mvaddstr(i++, 0, buf);
  1324. X    }
  1325. X    fclose(fp);
  1326. X    move(row, col);
  1327. X#endif /* SHAREDMEM */
  1328. X
  1329. X    refresh();
  1330. X    return;
  1331. X}
  1332. X
  1333. X/*
  1334. X * Zap the virtual screen file (or clear it)
  1335. X */
  1336. X
  1337. Xvoid
  1338. Xzap_vs()
  1339. X{
  1340. X#ifdef SHAREDMEM
  1341. X    status->clr = 1;
  1342. X#else /* SHAREDMEM */
  1343. X    unlink(status->vs_path);
  1344. X#endif /* SHAREDMEM */
  1345. X    return;
  1346. X}
  1347. SHAR_EOF
  1348. if test 2074 -ne "`wc -c < 'screen.c'`"
  1349. then
  1350.     echo shar: "error transmitting 'screen.c'" '(should have been 2074 characters)'
  1351. fi
  1352. fi
  1353. echo shar: "extracting 'st_line.c'" '(2103 characters)'
  1354. if test -f 'st_line.c'
  1355. then
  1356.     echo shar: "will not over-write existing file 'st_line.c'"
  1357. else
  1358. sed 's/^X//' << \SHAR_EOF > 'st_line.c'
  1359. X/*
  1360. X * Display the status line.  Up to now, we've never really cared how
  1361. X * large the physical screen was... but now we want the status line
  1362. X * on the bottom.
  1363. X */
  1364. X
  1365. X#include <curses.h>
  1366. X#include "config.h"
  1367. X#include "dial_dir.h"
  1368. X#include "misc.h"
  1369. X#include "modem.h"
  1370. X#include "param.h"
  1371. X#include "status.h"
  1372. X
  1373. Xvoid
  1374. Xst_line(message)
  1375. Xchar *message;
  1376. X{
  1377. X    extern int xmc;
  1378. X    WINDOW *sl_win, *newwin();
  1379. X    int d, x, y;
  1380. X    static char *dn[2] = {"FDX", "HDX"};
  1381. X    static char *ln[2] = {"LOG OFF", "LOG ON"};
  1382. X    static char *pn[2] = {"PTR OFF", "PTR ON "};
  1383. X    char buf[80], field_one[15], *cur_tty;
  1384. X
  1385. X                    /* is anybody missing? */
  1386. X    if (dir == NULL || modem == NULL || param == NULL)
  1387. X        return;
  1388. X                    /* remember where we parked the car.. */
  1389. X    getyx(stdscr, y, x);
  1390. X
  1391. X    sl_win = newwin(1, 80, LINES-1, 0);
  1392. X                    /* duplex message */
  1393. X    d = 0;
  1394. X    if (dir->duplex[dir->d_cur] == 'H')
  1395. X        d++;
  1396. X                    /* the current TTY */
  1397. X    cur_tty = "No TTY";
  1398. X    if (modem->t_cur != -1)
  1399. X        cur_tty = modem->tty[modem->t_cur];
  1400. X
  1401. X    /*
  1402. X     * The philosophy is:  If you press a command sequence that
  1403. X     * doesn't generate a window on the screen, then show the user
  1404. X     * what's going on in the status line.
  1405. X     */
  1406. X    if (*message == NULL)
  1407. X        sprintf(field_one, " %4.4s-0 HELP  ", param->ascii_hot);
  1408. X    else
  1409. X        sprintf(field_one, " %-13.13s", message);
  1410. X
  1411. X#ifdef XMC_BROKE
  1412. X    if (xmc > 0)
  1413. X        sprintf(buf, "%s | %-9.9s| %s | %5d %c%d%d | %-7.7s | %-7.7s | %-5.5s|%-5.5s",
  1414. X         field_one, cur_tty, dn[d], dir->baud[dir->d_cur],
  1415. X         dir->parity[dir->d_cur], dir->dbits[dir->d_cur],
  1416. X         dir->sbits[dir->d_cur], ln[status->log], pn[status->print],
  1417. X         param->cr_in, param->cr_out);
  1418. X    else
  1419. X#endif /* XMC_BROKE */
  1420. X        sprintf(buf, "%s | %-9.9s| %s | %5d %c%d%d | %-7.7s | %-7.7s | %-5.5s| %-5.5s",
  1421. X         field_one, cur_tty, dn[d], dir->baud[dir->d_cur],
  1422. X         dir->parity[dir->d_cur], dir->dbits[dir->d_cur],
  1423. X         dir->sbits[dir->d_cur], ln[status->log], pn[status->print],
  1424. X         param->cr_in, param->cr_out);
  1425. X
  1426. X    if (xmc > 0) {
  1427. X        touchwin(sl_win);
  1428. X        werase(sl_win);
  1429. X        wrefresh(sl_win);
  1430. X    }
  1431. X    wattrstr(sl_win, A_STANDOUT, buf);
  1432. X    wrefresh(sl_win);
  1433. X                    /* go ahead and delete it now */
  1434. X    delwin(sl_win);
  1435. X    move(y, x);
  1436. X    return;
  1437. X}
  1438. SHAR_EOF
  1439. if test 2103 -ne "`wc -c < 'st_line.c'`"
  1440. then
  1441.     echo shar: "error transmitting 'st_line.c'" '(should have been 2103 characters)'
  1442. fi
  1443. fi
  1444. echo shar: "extracting 'strings.c'" '(1329 characters)'
  1445. if test -f 'strings.c'
  1446. then
  1447.     echo shar: "will not over-write existing file 'strings.c'"
  1448. else
  1449. sed 's/^X//' << \SHAR_EOF > 'strings.c'
  1450. X/*
  1451. X * Miscellaneous string routines.
  1452. X */
  1453. X
  1454. X#include <stdio.h>
  1455. X
  1456. X/*
  1457. X * Do a fancy string copy.  If NULL, return null.  If pointer to NULL, then
  1458. X * return the special "null_ptr" variable.  If a normal copy, allocate
  1459. X * memory first.
  1460. X */
  1461. X
  1462. Xchar *
  1463. Xstrdup(str)
  1464. Xchar *str;
  1465. X{
  1466. X    extern char *null_ptr;
  1467. X    char *ret, *malloc(), *strcpy();
  1468. X
  1469. X    if (str == NULL)
  1470. X        return(NULL);
  1471. X                    /* if pointer to null */
  1472. X    if (*str == NULL)
  1473. X        return(null_ptr);
  1474. X
  1475. X    ret = malloc((unsigned int) strlen(str)+1);
  1476. X    strcpy(ret, str);
  1477. X    return(ret);
  1478. X}
  1479. X
  1480. X/*
  1481. X * Perform the free(2) function, but check for NULL and the special
  1482. X * "null_ptr" variable first.
  1483. X */
  1484. X
  1485. Xvoid
  1486. Xfree_ptr(str)
  1487. Xchar *str;
  1488. X{
  1489. X    extern char *null_ptr;
  1490. X    void free();
  1491. X
  1492. X    if (str != NULL && str != null_ptr)
  1493. X        free(str);
  1494. X    return;
  1495. X}
  1496. X
  1497. X/*
  1498. X * This routine is similar to strtok(3).  But our version handles null
  1499. X * strings and takes a single separator character as an argument.
  1500. X * Returns a NULL on end of string or error.
  1501. X */
  1502. X
  1503. Xchar *
  1504. Xstr_tok(str, c)
  1505. Xchar *str, c;
  1506. X{
  1507. X    extern char *null_ptr;
  1508. X    char *strchr();
  1509. X    static char *ptr, *sep;
  1510. X                    /* start at beginning */
  1511. X    if (str != NULL)
  1512. X        ptr = str;
  1513. X    else
  1514. X        ptr = sep;
  1515. X                    /* at the end? */
  1516. X    if (*ptr == NULL)
  1517. X        return(NULL);
  1518. X                    /* no separator? */
  1519. X    if (!(sep = strchr(ptr, c)))
  1520. X        return(NULL);
  1521. X                    /* zap the sep, move past it */
  1522. X    *sep = NULL;
  1523. X    sep++;
  1524. X
  1525. X    return(ptr);
  1526. X}
  1527. SHAR_EOF
  1528. if test 1329 -ne "`wc -c < 'strings.c'`"
  1529. then
  1530.     echo shar: "error transmitting 'strings.c'" '(should have been 1329 characters)'
  1531. fi
  1532. fi
  1533. echo shar: "extracting 'terminal.c'" '(9686 characters)'
  1534. if test -f 'terminal.c'
  1535. then
  1536.     echo shar: "will not over-write existing file 'terminal.c'"
  1537. else
  1538. sed 's/^X//' << \SHAR_EOF > 'terminal.c'
  1539. X/*
  1540. X * Start the terminal dialogue, fork the input routine, watch for the
  1541. X * hot key so we can execute an option.
  1542. X */
  1543. X
  1544. X#include <stdio.h>
  1545. X#include <curses.h>
  1546. X#include <signal.h>
  1547. X#include "config.h"
  1548. X#ifdef OLDCURSES
  1549. X#include <termio.h>
  1550. X#endif /* OLDCURSES */
  1551. X#ifdef UNIXPC
  1552. X#include <sys/phone.h>
  1553. X#include <fcntl.h>
  1554. X#endif /* UNIXPC */
  1555. X#include "dial_dir.h"
  1556. X#include "misc.h"
  1557. X#include "modem.h"
  1558. X#include "param.h"
  1559. X#include "status.h"
  1560. X
  1561. Xstatic int pid = -1;
  1562. X
  1563. Xterminal(input_status)
  1564. Xint input_status;
  1565. X{
  1566. X    extern int fd;
  1567. X    int i, k, cr_lf;
  1568. X    char c, lf=10, *strdup();
  1569. X    void help_screen(), line_set(), n_shell(), load_vs(), send_str();
  1570. X    void hang_up(), do_input(), list_dir(), pexit(), zap_vs();
  1571. X    void st_line(), chg_dir(), screen_dump(), input_off(), suspend();
  1572. X    void info(), term_mode();
  1573. X
  1574. X                    /* if starting out in command mode */
  1575. X    if (!input_status)
  1576. X        st_line("");
  1577. X                    /* put stdin/stdout in terminal mode */
  1578. X    resetterm();
  1579. X    term_mode();
  1580. X
  1581. X    if (input_status)
  1582. X        do_input();
  1583. X
  1584. X    while (1) {
  1585. X        read(0, &c, 1);
  1586. X                    /* is it the hot key? */
  1587. X        if (c == param->hot) {
  1588. X                    /* suspend input */
  1589. X            input_status = 0;
  1590. X            suspend(1);
  1591. X
  1592. X            /*
  1593. X             * Put in terminal in the curses mode, load the
  1594. X             * virtual screen and add the status line at the bottom.
  1595. X             */
  1596. X            fixterm();
  1597. X            load_vs();
  1598. X            st_line("");
  1599. X#ifndef OLDCURSES
  1600. X            keypad(stdscr, TRUE);
  1601. X#endif /* OLDCURSES */
  1602. X            i = wgetch(stdscr);
  1603. X                    /* map an additional hot key to -1 */
  1604. X            if (i == param->hot)
  1605. X                i = -1;
  1606. X                    /* look for options */
  1607. X            k = -1;
  1608. X            switch (i) {
  1609. X                case -1:    /* 2 "hots" means send 1 */
  1610. X                    k = param->hot;
  1611. X                    break;
  1612. X                case '0':    /* help screen */
  1613. X                    help_screen(param->ascii_hot);
  1614. X                    break;
  1615. X                case 'd':
  1616. X                case 'D':    /* dialing directory */
  1617. X                    if (dial_menu())
  1618. X                        input_status = dial_win();
  1619. X                    break;
  1620. X                case 'r':
  1621. X                case 'R':    /* redial */
  1622. X                    if (redial())
  1623. X                        input_status = dial_win();
  1624. X                    break;
  1625. X                case 'm':
  1626. X                case 'M':    /* keyboard macros */
  1627. X                    macro();
  1628. X                    break;
  1629. X                case 'p':
  1630. X                case 'P':    /* line settings */
  1631. X                    if (ls_menu())
  1632. X                        line_set();
  1633. X                    break;
  1634. X                case 'x':
  1635. X                case 'X':    /* exit */
  1636. X                    pexit();
  1637. X                    break;
  1638. X                case '4':    /* Unix gateway */
  1639. X                    n_shell();
  1640. X                    break;
  1641. X                case 'i':
  1642. X                case 'I':    /* Program info screen */
  1643. X                    info(0);
  1644. X                    break;
  1645. X                case 's':    /* setup menu */
  1646. X                case 'S':
  1647. X                    input_status = setup_menu();
  1648. X                    break;
  1649. X                case 'c':    /* clear the screen */
  1650. X                case 'C':
  1651. X                    zap_vs();
  1652. X                    erase();
  1653. X                    break;
  1654. X                case 'b':
  1655. X                case 'B':    /* Change directory */
  1656. X                    chg_dir();
  1657. X                    break;
  1658. X                case 'e':
  1659. X                case 'E':    /* toggle duplex */
  1660. X                    if (dir->duplex[dir->d_cur] == 'F')
  1661. X                        dir->duplex[dir->d_cur] = 'H';
  1662. X                    else
  1663. X                        dir->duplex[dir->d_cur] = 'F';
  1664. X
  1665. X                        /* show changes */
  1666. X                    st_line("");
  1667. X                    k = wait_key(stdscr, 2);
  1668. X                    break;
  1669. X                case 'h':
  1670. X                case 'H':    /* hang up phone */
  1671. X                    hang_up(1);
  1672. X                    input_off();
  1673. X                    break;
  1674. X                case 'l':
  1675. X                case 'L':    /* toggle printer */
  1676. X                    status->print = status->print ? 0 : 1;
  1677. X#ifndef SHAREDMEM
  1678. X                    if (pid != -1)
  1679. X                        kill(pid, SIGUSR2);
  1680. X#endif /* SHAREDMEM */
  1681. X                        /* show changes */
  1682. X                    st_line("");
  1683. X                    k = wait_key(stdscr, 2);
  1684. X                    break;
  1685. X                case '3':    /* toggle CR - CR/LF */
  1686. X                    if (!strcmp(param->cr_in, "CR")) {
  1687. X                        param->cr_in = strdup("CR/LF");
  1688. X                        status->add_lf = 1;
  1689. X                    }
  1690. X                    else {
  1691. X                        param->cr_in = strdup("CR");
  1692. X                        status->add_lf = 0;
  1693. X                    }
  1694. X#ifndef SHAREDMEM
  1695. X                    input_off();
  1696. X                    input_status++;
  1697. X#endif /* SHAREDMEM */
  1698. X                        /* show changes */
  1699. X                    st_line("");
  1700. X                    k = wait_key(stdscr, 2);
  1701. X                    break;
  1702. X                case '7':    /* break key */
  1703. X                    if (fd != -1)
  1704. X                        ioctl(fd, TCSBRK, 0);
  1705. X
  1706. X                    st_line("   break");
  1707. X                    break;
  1708. X#ifndef OLDCURSES
  1709. X                case KEY_UP:
  1710. X#endif /* OLDCURSES */
  1711. X                case 'u':
  1712. X                case 'U':    /* send files */
  1713. X                    input_status = xfer_menu(1);
  1714. X                    break;
  1715. X#ifndef OLDCURSES
  1716. X                case KEY_DOWN:
  1717. X                case '\n':
  1718. X#endif /* OLDCURSES */
  1719. X                case 'n':
  1720. X                case 'N':    /* receive files */
  1721. X                    input_status = xfer_menu(0);
  1722. X                    break;
  1723. X                case 't':
  1724. X                case 'T':
  1725. X                    input_status = pass_thru();
  1726. X                    break;
  1727. X                case 'f':
  1728. X                case 'F':    /* list directory */
  1729. X                    list_dir();
  1730. X                    break;
  1731. X                case 'g':    /* screen dump */
  1732. X                case 'G':
  1733. X                    screen_dump();
  1734. X                    st_line(" screen dump");
  1735. X                    k = wait_key(stdscr, 2);
  1736. X                    break;
  1737. X                case '1':    /* data logging */
  1738. X                    input_status = data_logging();
  1739. X                    break;
  1740. X                case '2':    /* toggle log */
  1741. X                    if (!strcmp(status->log_path, "NOT_DEFINED")) {
  1742. X                        beep();
  1743. X                        st_line(" no log file");
  1744. X                        k = wait_key(stdscr, 2);
  1745. X                        break;
  1746. X                    }
  1747. X                    status->log = status->log ? 0 : 1;
  1748. X#ifndef SHAREDMEM
  1749. X                    if (pid != -1)
  1750. X                        kill(pid, SIGUSR1);
  1751. X#endif /* SHAREDMEM */
  1752. X                        /* show changes */
  1753. X                    st_line("");
  1754. X                    k = wait_key(stdscr, 2);
  1755. X                    break;
  1756. X                /*
  1757. X                 * The following are the keyboard macros
  1758. X                 * corresponding to the shifted number keys.
  1759. X                 * (Too many keys... [control] [A] [shift] [1]
  1760. X                 * is hardly a shortcut!)
  1761. X                 */
  1762. X                case '!':
  1763. X                    send_str(param->mac_1);
  1764. X                    break;
  1765. X                case '@':
  1766. X                    send_str(param->mac_2);
  1767. X                    break;
  1768. X                case '#':
  1769. X                    send_str(param->mac_3);
  1770. X                    break;
  1771. X                case '$':
  1772. X                    send_str(param->mac_4);
  1773. X                    break;
  1774. X                case '%':
  1775. X                    send_str(param->mac_5);
  1776. X                    break;
  1777. X                case '^':
  1778. X                    send_str(param->mac_6);
  1779. X                    break;
  1780. X                case '&':
  1781. X                    send_str(param->mac_7);
  1782. X                    break;
  1783. X                case '*':
  1784. X                    send_str(param->mac_8);
  1785. X                    break;
  1786. X                case '(':
  1787. X                    send_str(param->mac_9);
  1788. X                    break;
  1789. X                case ')':
  1790. X                    send_str(param->mac_0);
  1791. X                    break;
  1792. X                default:
  1793. X                    fputc(BEL, stderr);
  1794. X                    break;
  1795. X            }
  1796. X
  1797. X            /*
  1798. X             * Repaint the stdscr (if we are already talking),
  1799. X             * get the stdin/stdout out of the curses mode and
  1800. X             * into the terminal mode.
  1801. X             */
  1802. X            if (fd != -1) {
  1803. X                touchwin(stdscr);
  1804. X                refresh();
  1805. X            }
  1806. X            resetterm();
  1807. X            term_mode();
  1808. X
  1809. X            /*
  1810. X             * Some of the output processing options have to be
  1811. X             * faked...  Unfortunately, adding a LF to CR on
  1812. X             * output is one of them.
  1813. X             */
  1814. X            cr_lf = !strcmp(param->cr_out, "CR/LF");
  1815. X
  1816. X                    /* re-start input routine */
  1817. X            if (input_status)
  1818. X                do_input();
  1819. X            else
  1820. X                suspend(0);
  1821. X
  1822. X            /*
  1823. X             * If you pressed a key during one of the sleeping
  1824. X             * periods (typically the delay to see the status
  1825. X             * line change), let the keyboard value fall thru
  1826. X             * to the write() below.
  1827. X             */
  1828. X            if (k == -1)
  1829. X                continue;
  1830. X            c = k;
  1831. X        }
  1832. X                    /* ignore errors if fd == -1 */
  1833. X        write(fd, &c, 1);
  1834. X                    /* map cr to cr_lf? */
  1835. X        if (c == '\r' && cr_lf)
  1836. X            write(fd, &lf, 1);
  1837. X    }
  1838. X}
  1839. X
  1840. X/*
  1841. X * Put the stdin/stdout in terminal mode.  We've divided up the
  1842. X * responsibility for the line settings options between the serial port
  1843. X * and the stdin and stdout.
  1844. X */
  1845. X
  1846. Xvoid
  1847. Xterm_mode()
  1848. X{
  1849. X    struct termio tbuf;
  1850. X
  1851. X    ioctl(0, TCGETA, &tbuf);
  1852. X
  1853. X    tbuf.c_cc[4] = 1;        /* VMIN */
  1854. X    tbuf.c_cc[5] = 0;        /* VTIME */
  1855. X    tbuf.c_iflag = 0;
  1856. X    tbuf.c_oflag = 0;
  1857. X    tbuf.c_lflag = 0;
  1858. X                    /* duplex */
  1859. X    if (dir->duplex[dir->d_cur] == 'H')
  1860. X        tbuf.c_lflag = ECHO;
  1861. X
  1862. X    ioctl(0, TCSETA, &tbuf);
  1863. X    ioctl(0, TCFLSH, 2);
  1864. X    return;
  1865. X}
  1866. X
  1867. X/*
  1868. X * Fire up the input routine...
  1869. X */
  1870. X
  1871. Xstatic void
  1872. Xdo_input()
  1873. X{
  1874. X    extern int fd;
  1875. X    void error_win();
  1876. X    char first[(sizeof(int)*8)+1];
  1877. X#ifdef SHAREDMEM
  1878. X    extern int shm_id;
  1879. X#else /* SHAREDMEM */
  1880. X    char add_lf[2], log[2], print[2];
  1881. X#endif /* SHAREDMEM */
  1882. X                    /* if no TTY, or already on */
  1883. X    if (pid != -1 || fd == -1)
  1884. X        return;
  1885. X
  1886. X    status->fd = fd;
  1887. X    if (!strcmp(param->cr_in, "CR/LF"))
  1888. X        status->add_lf = 1;
  1889. X    else
  1890. X        status->add_lf = 0;
  1891. X
  1892. X#ifdef SHAREDMEM
  1893. X    sprintf(first, "%d", shm_id);
  1894. X#else /* SHAREDMEM */
  1895. X    sprintf(first, "%d", status->fd);
  1896. X    sprintf(add_lf, "%d", status->add_lf);
  1897. X    sprintf(log, "%d", status->log);
  1898. X    sprintf(print, "%d", status->print);
  1899. X#endif /* SHAREDMEM */
  1900. X
  1901. X                    /* fork the input routine */
  1902. X    if (!(pid = fork())) {
  1903. X#ifdef SETUGID
  1904. X        setuid(getuid());
  1905. X        setgid(getgid());
  1906. X#endif /* SETUGID */
  1907. X#ifdef SHAREDMEM
  1908. X        execlp("pcomm_input", "pcomm_input", first, (char *) 0);
  1909. X#else /* SHAREDMEM */
  1910. X        execlp("pcomm_input", "pcomm_input", first, add_lf, log,
  1911. X         print, status->log_path, status->vs_path, (char *) 0);
  1912. X#endif /* SHAREDMEM */
  1913. X        error_win(1, "Cannot find (or execute) the 'pcomm_input' program", "");
  1914. X    }
  1915. X
  1916. X    return;
  1917. X}
  1918. X
  1919. X/*
  1920. X * shut it down...
  1921. X */
  1922. X
  1923. Xvoid
  1924. Xinput_off()
  1925. X{
  1926. X    if (pid != -1) {
  1927. X        kill(pid, SIGTERM);
  1928. X        pid = -1;
  1929. X    }
  1930. X    return;
  1931. X}
  1932. X
  1933. X/*
  1934. X * Hang up the phone but remain in the Pcomm command state.  Uses the
  1935. X * hang_up string only, does *not* drop the DTR!
  1936. X */
  1937. X
  1938. Xvoid
  1939. Xhang_up(verbose)
  1940. Xint verbose;
  1941. X{
  1942. X    extern int fd;
  1943. X    void send_str(), st_line(), line_set();
  1944. X#ifdef UNIXPC
  1945. X    char buf[40], *strcpy(), *ttyname();
  1946. X#endif /* UNIXPC */
  1947. X                    /* sanity checking */
  1948. X    if (modem == NULL)
  1949. X        return;
  1950. X                    /* anything to hang up? */
  1951. X    if (modem->m_cur == -1 || fd == -1)
  1952. X        return;
  1953. X
  1954. X    if (verbose)
  1955. X        st_line("disconnecting");
  1956. X                    /* special case for OBM */
  1957. X#ifdef UNIXPC
  1958. X    if (!strcmp(modem->mname[modem->m_cur], "OBM")) {
  1959. X        ioctl(fd, PIOCDISC);
  1960. X        /*
  1961. X         * The PIOCDISC ioctl screws up the file descriptor!!!
  1962. X         * No other phone(7) ioctl can fix it.  Whatever it does,
  1963. X         * it seems to escape detection with PIOCGETA and TCGETA.
  1964. X         * The best I can do is close the port and start over.
  1965. X         */
  1966. X        strcpy(buf, ttyname(fd));
  1967. X        close(fd);
  1968. X        fd = open(buf, O_RDWR|O_NDELAY);
  1969. X        fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY);
  1970. X        line_set();
  1971. X    }
  1972. X    else
  1973. X#endif /* UNIXPC */
  1974. X        send_str(modem->hang_up[modem->m_cur]);
  1975. X
  1976. X    if (verbose)
  1977. X        st_line("");
  1978. X    return;
  1979. X}
  1980. X
  1981. X/*
  1982. X * Suspend or un-suspend the input routine.  The argument is used in
  1983. X * non-shared memory configurations to give the vs_path file a fighting
  1984. X * chance of being written to disk before load_vs() reads it.
  1985. X */
  1986. X
  1987. X/*ARGSUSED*/
  1988. Xvoid
  1989. Xsuspend(on)
  1990. Xint on;
  1991. X{
  1992. X    unsigned int sleep();
  1993. X
  1994. X    if (pid == -1)
  1995. X        return;
  1996. X    kill(pid, SIGINT);
  1997. X#ifndef SHAREDMEM
  1998. X    if (on)
  1999. X        sleep(1);
  2000. X#endif /* SHAREDMEM */
  2001. X    return;
  2002. X}
  2003. SHAR_EOF
  2004. if test 9686 -ne "`wc -c < 'terminal.c'`"
  2005. then
  2006.     echo shar: "error transmitting 'terminal.c'" '(should have been 9686 characters)'
  2007. fi
  2008. fi
  2009. exit 0
  2010. #    End of shell archive
  2011.  
  2012. -- 
  2013. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  2014.